package com.hljx.controller;

import io.swagger.v3.oas.annotations.Operation;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.core.JobParametersInvalidException;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException;
import org.springframework.batch.core.repository.JobRestartException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 住院非药品明细表
 *
 * @author cw
 */

@RestController
@RequestMapping("/IfFeeItem")
public class IfFeeItemListController {
    @Autowired
    private JobLauncher jobLauncher;
    @Autowired
    @Qualifier("ifFeeitemListJob")
    private Job sampleJob;

    @Operation(description = "住院非药品明细表")
    @GetMapping("/ifFeeitemListJob")
    public void runIfFeeitemListJob() throws JobParametersInvalidException, JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException {
        JobParameters jobParameters = new JobParametersBuilder()
                .addLong("time",System.currentTimeMillis())
                .addString("startDate", "2024-07-01 00:00:00")
                .addString("endDate","2024-09-30 23:59:59")
//                .addString("start","20240401" )
//                .addString("end","20240701")
//                 .addString("startTime", "2024-04-01")
//                .addString("endTime","2024-06-30")
//                .addString("year","2024")
//                .addString("month","2")
                .addString("splitTableName","20243")
                .toJobParameters();
        jobLauncher.run(sampleJob, jobParameters);
    }

}
